﻿<%@ Page Language="C#" %>

<%@ Import Namespace="wojilu" %>
<%@ Import Namespace="wojilu.View" %>
<%@ Import Namespace="wojilu.Apps.Qycms.Domain" %>
<%@ Import Namespace="wojilu.Apps.Qycms.Service" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>#{softtitle}</title>
<link href="#{path.css}ybb/css/baselist.css?v=#{cssVersion}" rel="stylesheet" type="text/css" />
<link href="#{path.css}ybb/css/all.css?v=#{cssVersion}" rel="stylesheet" type="text/css" />
<link href="#{path.css}ybb/css/formdiv.css?v=#{cssVersion}" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="#{path.js}ybb/js/jquery.js?v=#{jsVersion}"></script>
<script type="text/javascript" src="#{path.js}ybb/js/control.js?v=#{jsVersion}"></script>
<script type="text/javascript" src="#{path.js}ybb/js/form.js?v=#{jsVersion}"></script>
<script type="text/javascript">

	var resizewindow= null;

	window.onresize = function(){
		var h = $(window).height();
		if(resizewindow!=h){
			sizewindow();
			resizewindow=h;
		}
	}

	function sizewindow(){
		var h = $(window).height();
		if(document.getElementById("mainbodybottonauto")){
			$('.managebottonadd').css({height:h-40});
		}
	}
	var createmain_js_mid_empty = "_{createmain_js_mid_empty}";
	var createmain_js_pnumber_empty = "_{createmain_js_pnumber_empty}";
	var createmain_js_tid_empty = "_{createmain_js_tid_empty}";
	var createmain_js_add_ok = "_{createmain_js_add_ok}";
	var createmain_js_add_no = "_{createmain_js_add_no}";
	var iframename = "#{iframename}";
	$(document).ready(function(){
	    var h = '#{iframeheightwindow}';
		$('.managebottonadd').css({height:h-40});
		var optionstype = {

			beforeSubmit: formverify_type,
			success:saveResponse
		}
		$("#creattype").submit(function() {
			$(this).ajaxSubmit(optionstype);
			return false;
		});
	})

	function formverify_type(formData, jqForm, options) {
		var queryString = $.param(formData);
		var get=urlarray(queryString);
		if(get['mid']==0){
			document.creattype.mid.focus();
			alert(createmain_js_mid_empty);
			return false;
		}
		if(get['pnumber'].match(/^[1-9]{1}[0-9]*$/ig)==null) {
			document.creattype.pnumber.focus();
			alert(createmain_js_pnumber_empty);
			return false;
		}
		if(get['creattype']==0){
			if(get['tid']==0){
				document.creattype.tid.focus();
				alert(createmain_js_tid_empty);
				return false;
			}
		}
		var loadurl = '<%=link.to(new wojilu.Web.Controller.Admin.Qycms.CreateController().CreateTypeWindow) %>?lng=' + get['lng'] + '&mid=' + get['mid'] + '&tid=' + get['tid'] + '&creattype=' + get['creattype'] + '&pnumber=' + get['pnumber'];
		parent.windowsdig('Loading','iframe:'+loadurl,'750px','400px','iframe',false);
		return false;
	}
	function saveResponse(options){
		parent.closeifram();
		if (options=='true'){
			alert(createmain_js_add_ok);
		}else{
			alert(createmain_js_add_no);
		}
		parent.onaletdoc()
	}

	function searchoption(mid,title){
		var lng=document.creattype.lng.value;
		lng = (lng=='big5') ? 'cn' : lng;
		selectlinkagelng('tid', '<%=link.to(new wojilu.Web.Controller.Admin.Qycms.CreateController().ScTypeList) %>?islinkd=1&optiontitle=' + title + '&mid=' + mid + '&lng=' + lng);
	}

	function lngtype(lng){
		lng = (lng=='big5') ? 'cn' : lng;
		selectlinkagelng('midbotton', '<%=link.to(new wojilu.Web.Controller.Admin.Qycms.CreateController().ScModelList) %>?lng=' + lng);
		searchoption(1000000, "_{all_botton}");
	}
</script>
</head>

<body>
<form method="post" name="creattype" id="creattype" action="#{ActionLink}">
<div id="mainbodybottonauto" class="managebottonadd">
	<div class="maindobycontent">
		<div class="suggestion">
			<span class="sugicon"><span class="strong colorgorning2">_{position_title}</span><span class="colorgorningage">_{createmain_add_mess}</span></span>
		</div>
		<div class="manageeditdiv">
			<div class="maneditcontent">
				<table class="formtable">
					<tr class="trstyle2">
						<td class="trtitle01">_{createmain_add_lng}</td>
						<td class="trtitle02">
                            <%var is_alonelng = v.data("is_alonelng").ObjectToInt(); %>
							<%if (is_alonelng == 1) { %>
								#{home_lng}
								<input type="hidden" name="lng" id="lng" value="#{home_lng}" />
							<%}else { %>
								<select size="1" name="lng" id="lng" onchange="javascript:lngtype(this.value);">
                                    <%var lnglist = v.data("lnglist") as List<Lng>; %>
								<%foreach (var row in lnglist) { %>
									<option <%if (row.lng == v.data("home_lng").ToString()) { %>selected<%} %> value="<%=row.lng %>"><%=row.lngtitle %></option>
								    <%} %>
								</select>
							<%} %>
						</td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle01">_{createmain_add_mid}</td>
						<td class="trtitle02">
							<select size="1" name="mid" id="midbotton" onchange="javascript:searchoption(this.value,'_{all_botton}')">
								<option value="0">_{createmain_add_mid_option}</option>
                                <%var mlist = v.data("mlist") as List<Model>; %>
                                <%foreach(var row in mlist){ %>
								<option value="<%=row.Id %>"><%=row.modelname %></option>
								<%} %>
							</select>
						</td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle01">_{createmain_add_tid}</td>
						<td class="trtitle02">
							<select size="1" name="tid" id="tid">
								<option value="0">_{all_botton}</option>
							</select>
						</td>
					</tr>
					<tr class="trstyle2">
						<td width="15%" class="trtitle01">_{createmain_add_creattype}</td>
						<td width="85%" class="trtitle02">
							<input type="radio" value="1" name="creattype" checked="checked"/> _{createmain_add_creattype1}&nbsp;
							<input type="radio" value="0" name="creattype"/> _{createmain_add_creattype2}
							<span class="cautiontitle">_{createmain_add_creattype_mess}</span>
						</td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle01">_{createmain_add_pnumber}</td>
						<td class="trtitle02">
							<input type="text" name="pnumber" size="5" maxlength="4" value="30" class="infoInput"/>
							<span class="cautiontitle">_{createmain_add_pnumber_mess}</span>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>
<div id="downbotton">
	<div id="subbotton">
		<table border="0" width="100%">
			<tr>
				<td><input type="submit" name="Submit" value="_{botton_cerathtml}" class="buttonface" /></td>
			</tr>
		</table>
	</div>
</div>
</form>
</body>

</html>